package com.jk.smartelderlycare.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.jk.smartelderlycare.dao.SysShipmentsMapper;
import com.jk.smartelderlycare.dto.SysShipments;
import com.jk.smartelderlycare.pojo.PagedResponse;
import com.jk.smartelderlycare.service.SysShipmentsService;
import com.jk.smartelderlycare.utils.PaginationUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author hhk
 * @version 1.0
 * @ClassName SysShipmentsServiceImpl
 * @program: smart-elderly-care
 * @description: TODO
 * @date 2024/12/5 18:44
 */
@Service
public class SysShipmentsServiceImpl implements SysShipmentsService {

    @Autowired
    private SysShipmentsMapper sysShipmentsMapper;

    @Override
    public PagedResponse<SysShipments> findShipmentsPaginationList(SysShipments sysShipments, Integer pageNum, Integer pageSize) {
        Page<Object> page = new Page<>(pageNum,pageSize);
       IPage<SysShipments> shipmentsIPage =  sysShipmentsMapper.findShipmentsPaginationList(sysShipments,page);

        return PaginationUtil.getPagedResponse(shipmentsIPage.getRecords(),pageNum,pageSize,shipmentsIPage.getTotal());
    }

    @Override
    public List<SysShipments> findShipmentsList() {
        return sysShipmentsMapper.selectList(null);
    }

    @Override
    public void addShipments(SysShipments sysShipments) {
        sysShipmentsMapper.insert(sysShipments);
    }
}
